import { defineConfig, loadEnv } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/


export default defineConfig(({ mode, command }) => {
  const env = loadEnv(mode, process.cwd())
  let plugins = [
    react(),
  ];
  return {
    // envPrefix: 'VITE_', // 默认前缀，可修改
    plugins,
    base: './',
    build: {
      outDir: 'reactSystem', // 输出目录
    },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
        }
      }
    },
    server: {
      // 关键配置：让所有路由都返回 index.html
      historyApiFallback: true,
      host: '0.0.0.0',
      proxy: {
        '/gaixc/jiliangModel': {  // 算法大模型
          // target: 'http://192.168.40.21:9000',
          // target: 'http://192.168.161.146:9000',
          target: 'http://192.168.211.55:9002',
          // target: 'http://192.168.231.182:9002',
          // target: 'http://192.168.43.147:9002',
          // target: 'http://192.168.210.56:9002',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/gaixc\/jiliangModel/, ''),
        }
      }
    }
  }
})

